//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing;

namespace OpenLS.Chart
{
    internal class ReadContextData
    {
        public readonly AxisResolver AxesResolver;
        public readonly IReferenceFactory ReferenceResolver;
        public readonly IThemedElement ThemeOwner;

        public ReadContextData(AxisResolver axesResolver, IThemedElement themeOwner, IReferenceFactory referenceResolver)
        {
            ThemeOwner = themeOwner;
            AxesResolver = axesResolver;
            ReferenceResolver = referenceResolver;
        }

        internal static AxisResolver GetAxisResolver(ReadContext ctx)
        {
            return ctx.GetData<AxisResolver>();
        }

        internal static IThemedElement GetThemeOwner(ReadContext ctx)
        {
            return ctx.GetData<IThemedElement>();
        }

        internal static IReferenceFactory GetReferenceFactory(ReadContext ctx)
        {
            var result =  ctx.GetData<IReferenceFactory>();
            if (result == null)
                result = new CannonicalReferenceFactory();
            return result;
        }
    }
}